<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://people">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/navigation.xsl" />
	<xsl:include href="blocks.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/people.css" type="text/css" media="all" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />
			
			<!-- Header -->
			<div id="header">
				<xsl:call-template name="logo" />
				
				<!-- Menu -->
				<xsl:call-template name="menu" />
			</div>
			<!-- /Header -->
			
			<!-- Blocks -->
			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
					
					<div class="stat_block">
						<h4>&labelBlockStat; ↓</h4>
						<p>
							<xsl:apply-templates select="document('xmodule://people/stat')/data/response/gender" mode="block-stat" />
						</p>
					</div>
					
					<div class="stat_block tags">
						<h4>&labelBlockCountries;</h4>
						<p>
							<xsl:apply-templates select="document('xmodule://people/getUsersCountries')/data/response/countries" mode="block-countries" />
						</p>
					</div>
					
					<div class="stat_block tags">
						<h4>&labelBlockCities;</h4>
						<p>
							<xsl:apply-templates select="document('xmodule://people/getUsersCities')/data/response/cities" mode="block-cities" />
						</p>
					</div>
				</div>
			</div>
			<!-- // Blocks -->
			
			<!-- Content -->
			<div id="content">
				<div id="content_inner">
					<div id="people_left">
						<div id="people_left_inner">
							<h1>&labelSearchMan; ↓</h1>
							<div id="people_search">
								<form action="{$baseURI}/people/search" method="get">
									<input style="width:80%" type="text" name="word" value="" />
									<xsl:text> </xsl:text>
									<input type="submit" value="→" />
								</form>
							</div>
							
							<h1>&labelNewUsers; ↓</h1>
							<div id="new_users">
								<xsl:apply-templates select="document('xmodule://people/getNewUsers')/data/response/object" mode="new-users" />
							</div>
						</div>
					</div>
					<div id="people_main">
						<h1>&labelRating; ↓</h1>
						<div id="people_main_inner">
							<xsl:apply-templates select="response/object[@type='user']" />
						</div>
						<xsl:apply-templates select="response/pages" mode="pages-navigation">
							<xsl:with-param name="href">
								<xsl:value-of select="$baseURI" />
								<xsl:text>/people</xsl:text>
							</xsl:with-param>
						</xsl:apply-templates>
					</div>
				</div>
			</div>
			<!-- // Content -->
			
			<!-- Address -->
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response/object[@type='user']">
		<xsl:param name="login" select="property[@name='login']/value" />
		<xsl:param name="avatar" select="property[@name='avatar']/value" />
		
		<div class="item">
			<div class="rating">
				<xsl:value-of select="property[@name='rating']/value" />
			</div>
			<div class="username">
				<a href="{$baseURI}/user/{$login}">
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-avatar-small.png" alt="" />
					</xsl:if>
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_24_24{$avatar}" alt="" />
					</xsl:if>
				</a>
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="property[@name='name']/value" />
				</a>
			</div>
		</div>
	</xsl:template>
	
	<!-- NEW USERS -->
	<xsl:template match="object[@type='user']" mode="new-users">
		<xsl:param name="login" select="property[@name='login']/value" />
		<xsl:param name="avatar" select="property[@name='avatar']/value" />
		
		<div class="user_item">
			<div class="avatar">
				<a href="{$baseURI}/user/{$login}">
					<xsl:if test="$avatar = ''">
						<img src="{$baseURI}/images/default-avatar.png" alt="" />
					</xsl:if>
					<xsl:if test="$avatar != ''">
						<img src="{$baseURI}/thumb_50_50{$avatar}" alt="" />
					</xsl:if>
				</a>
			</div>
			<div class="signatire_name">
				<a href="{$baseURI}/user/{$login}">
					<xsl:value-of select="property[@name='name']/value" />
				</a>
			</div>
			<div class="signatire_date">
				<xsl:value-of select="property[@name='date']/value" />
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>